package com.example.chatzsyproject.adapter;


import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.chatzsyproject.R;
import com.example.chatzsyproject.app.MyApplication;
import com.example.chatzsyproject.model.MessageModel;

import java.util.List;

/**
 *
 */
public class MessageAdapter extends BaseQuickAdapter<MessageModel, BaseViewHolder> {

    public MessageAdapter(int layoutResId, @Nullable List<MessageModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MessageModel item) {
        helper.setText(R.id.tv_name, item.getName());
        helper.setText(R.id.tv_content, item.getContent());
        helper.setText(R.id.tv_time, item.getTime());
        if(item.getNum() == 0){
            helper.getView(R.id.tv_num).setVisibility(View.GONE);
        }else {
            helper.setText(R.id.tv_num, item.getNum()+"");
        }
        ImageView im_head = helper.getView(R.id.im_head);
        Glide.with(MyApplication.getInstance()).load(item.getIma()).into(im_head);
    }
}
